//
//  UserDefinedCellForSubView3ForGetJobSheet.m
//  HondaPro_2
//
//  Created by Eric on 13-6-21.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "UserDefinedCellForSubView3ForGetJobSheet.h"

@interface UserDefinedCellForSubView3ForGetJobSheet ()

//创建labels
-(void)initLabelsOnCell;

@end

@implementation UserDefinedCellForSubView3ForGetJobSheet

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        [self initLabelsOnCell];
        
//        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.selectionStyle = UITableViewCellSelectionStyleGray;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 创建labels

-(void)initLabelsOnCell
{
    
    //@"DISCOUNT",
    self.arrForAllLabelsKeysOnCell = [NSArray arrayWithObjects:
                                      @"CHARGE_PARTITION_CODE",
                                      @"ADD_ITEM_CODE",
                                      @"ADD_ITEM_NAME",
                                      @"ADD_ITEM_AMOUNT", nil];
    
    
    self.dicForAllLabelsOnCell = [NSMutableDictionary dictionaryWithCapacity:[_arrForAllLabelsKeysOnCell count]];
    CGFloat lblY = 0;
    
    CGFloat lblH = 50;
    
    CGFloat lblW = 198;
    for (int i = 0; i<[_arrForAllLabelsKeysOnCell count]; i++)
    {
        NSString *strKeys = [_arrForAllLabelsKeysOnCell objectAtIndex:i];
        CGRect rect = CGRectMake(i * lblW, lblY, lblW, lblH);
        UILabel *lbl = [[UILabel alloc] init];
        lbl.frame = rect;
        lbl.backgroundColor = [UIColor clearColor];
        lbl.textColor = [UIColor grayColor];
        lbl.font = [UIFont fontWithName:@"ArialMT" size:16];
        lbl.numberOfLines = 2;
        [self.dicForAllLabelsOnCell setObject:lbl forKey:strKeys];
        lbl.textAlignment=NSTextAlignmentCenter;
        [self.contentView addSubview:lbl];
        
        lbl.numberOfLines = 2;
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w=self.bounds.size.width/_arrForAllLabelsKeysOnCell.count;
    int i=0;
    for (UILabel*label in self.contentView.subviews) {
        label.frame=CGRectMake(i*w, 0, w, self.bounds.size.height);
        i++;
    }
}

@end
